package org.cosmact.designer.vxml.gefeditor.editpart;

import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.gef.LayerConstants;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;

public abstract class AbstractVxmlEditPart extends AbstractGraphicalEditPart
		implements LayerConstants, Adapter {

	@Override
	public void activate() {
		if (!isActive()) {
			super.activate();
			Notifier notified = (Notifier) getModel();
			notified.eAdapters().add(this);
		}
	}

	@Override
	public void deactivate() {
		if (isActive()) {
			super.deactivate();
			Notifier notified = (Notifier) getModel();
			notified.eAdapters().remove(this);
		}
	}

	@Override
	public Notifier getTarget() {
		return (Notifier) getModel();
	}

	@Override
	public boolean isAdapterForType(Object type) {
		return type.equals(getModel().getClass());
	}

	@Override
	public void setTarget(Notifier newTarget) {
		setModel(newTarget);
	}
}
